package com.liu.sx.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayUtils {



    //System.arraycopy()方法
    public static byte[] byteMerger(byte[] bt1, byte[] bt2){
        byte[] bt3 = new byte[bt1.length+bt2.length];
        System.arraycopy(bt1, 0, bt3, 0, bt1.length);
        System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
        return bt3;
    }

    public  static  int  sumByte(byte[] sum,int result){
        for(int i=0;i<sum.length;i++){
            result+=sum[i];
        }
        return result;

    }

    public  static  int  sumByte(byte[] sum){
        int result=0;
        System.out.println("虫子长度：++"+Arrays.toString(sum));

        for(int i=0;i<sum.length;i++){
//            处理byte 转int 中的那点尴尬
            result+=sum[i]&0xff;
        }
        return result;

    }

    public static void reverseArray(byte[] arr) {

    for (int i = 0;i < arr.length / 2 ; i++) {


        byte temp = arr[i];

    arr[i] = arr[arr.length-1-i];

    arr[arr.length-1-i] = temp;

    }

}

    /**
     *  补位器
     * @param s
     * @param num
     * @return
     */
    public static String add0ForLength(String s,int num){
        while (true){
            if (s.length()> num-1){
                break;
            }
            s="0"+s;
            System.out.println(s);
        }
        return s;
    }


    public static void main(String[] args) {
        byte[] arr ={1,2,3,4,5};
        reverseArray(arr);
        System.out.println(Arrays.toString(arr));
    }


}
